﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.XLANGs.BaseTypes;
using System.IO;
using System.Xml;

namespace BizMock
{
    public sealed class Transform
    {
        private static TransformInfo _transformInfo = new TransformInfo();

        internal class TransformInfo
        {           
            internal MessageVerifierBase MessageVerifier { get; set; }

            internal string[] Files { get; set; }

            internal string[] TransformedFiles { get; set; }

            internal TransformBase Map { get; set; }
        }

        private static void transformFiles()
        {
            _transformInfo.TransformedFiles = BizMockery.Instance.Transform( _transformInfo.Files, _transformInfo.Map );
        }

        private static void verifyTransformedMessageContents()
        {
            BizMockery.Instance.ValidateMessageContents(_transformInfo.TransformedFiles, _transformInfo.MessageVerifier);
        }

        public static MapInfo Message(params string[] files)
        {
            _transformInfo.Files = files;
            return new MapInfo();
        }

        public static MapInfo Message(BizMockMessage message)
        {
            _transformInfo.Files = message.Files;
            return new MapInfo();
        }

        public sealed class MapInfo
        {
            public VerifyInfo With( TransformBase map)
            {
                _transformInfo.Map = map;
                transformFiles();
                return new VerifyInfo();
            }
        }

        public sealed class VerifyInfo
        {
            public void Verify(FlatMessageVerifier verifier)
            {
                _transformInfo.MessageVerifier = verifier;
                verifyTransformedMessageContents();
            }
        }

    }
}
